package edu.sctu.boot.admin.generator.crud;

public class GeneratorConf {

    // 为每一个表创建一套CRUD代码
    public static final String PROJECT_ROOT_PATH = "E:\\hl\\hl-admin"; //(1)修改为本地项目路径
    public static final String PACKAGE_ROOT = "com.hb0730.boot.admin";
    public static final String GENERATED_TABLE_NAME = "t_spg_poi"; //(2)修改表名
    public static final String PROJECT_BIZ_NAME = getBizName(GENERATED_TABLE_NAME);
    public static final String PACKAGE_BIZ_NAME = ".project." + getBizName(GENERATED_TABLE_NAME);
    public static final String GENERATED_TABLE_NAME_PREFIX = getPrefix(GENERATED_TABLE_NAME);
    public static final String GENERATED_TABLE_NAME_NO_PREFIX = removePrefix(GENERATED_TABLE_NAME);

    // 获得业务模块名称
    // 所有业务流程相关代码统一放在project包下面，其中sys是系统管理相关代码，monitor是系统监控，cmn是通用业务代码
    public static final String getBizName(String raw) {
        return getTokens(raw)[1];
    }

    public static final String getPrefix(String raw) {
        String[] result = new String[2];
        for (int i = 0; i < 2; i++) {
            result[i] = getTokens(raw)[i];
        }
        return String.join("_", result);
    }

    public static final String removePrefix(String raw) {
        return raw.replace(getPrefix(raw), "").replace("_", "");
    }

    public static final String[] getTokens(String raw) {
        String[] tokens = raw.split("_");

        return tokens;
    }
}
